//
//  SeeButtonViewController.m
//  Zaker
//
//  Created by lirui on 16/3/11.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "SeeButtonViewController.h"

#import "SeeListTableVIewCell.h"
@interface SeeButtonViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong) NSMutableArray *dataArr;
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic ,strong)NSMutableArray *tidArr;
@property(nonatomic, strong) RadioModel *m;
@property(nonatomic, assign)BOOL isrefresh;
@end

@implementation SeeButtonViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
  
    [self data];
    [self creatTableView];
    
  }
-(void)data
{ NSString *str = [NSString stringWithFormat:@"http://c.3g.163.com/nc/topicset/android/radio/%@/0-20.html",_string ];
    [LHAFNetworkTool getUrl:str body:nil response:LHJSON requestHeadFile:nil success:^(NSURLSessionDataTask *task, id resposeObject) {
        
        self.dataArr = [ NSMutableArray array];
        self.tidArr = [ NSMutableArray array];
               for (NSDictionary *dic in resposeObject[@"tList"]) {
            RadioModel *model = [[ RadioModel alloc] init];
            RadioModel *model1 = [[RadioModel alloc] init];
            [model1 setValuesForKeysWithDictionary:dic];
            [model setValuesForKeysWithDictionary:dic[@"radio"]];
            [self.dataArr addObject:model];
            [self.tidArr addObject:model1];
           
                   }
         [_tableView reloadData];
        
     
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
    
}
-(void)creatTableView
{
    self.tableView = [[ UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH * 375, HEIGHT * 667) style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.tableView];
    
    [self.tableView registerClass:[SeeListTableVIewCell class] forCellReuseIdentifier:@"cell"];
    
       
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SeeListTableVIewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    RadioModel *m = _dataArr[indexPath.row];
    cell.title.text= m.tname;
    cell.detail.text = m.title;
    [cell.imgView sd_setImageWithURL:[NSURL URLWithString:m.imgsrc]];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return  cell;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{
    return 120 *HEIGHT;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    SeeRadioViewController *radio = [[ SeeRadioViewController alloc] init];
    radio.tidString = [_tidArr[indexPath.row] tid];
//    radio.posTidStr  = [_dataArr[indexPath.row] postid];
    [self.navigationController pushViewController:radio animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
